/**
     * @class
     * @description Box v tvare U
     * @param x {int} 
     * @param y {int} 
     * @param width {int} sirka boxu
     * @param height {int} vyska boxu  
     */                               
function Box(x,y,w,h,world,level,path){
    this.world = world;
    this.level = level;
    this.path  = path;
        
    this.x = x;
    this.y = y;
    this.width = w;
    this.height = h;
        
        
    this.makeBox = makeBox;
    this.makeStaticBox = makeStaticBox;
    this.makeVisibleStaticBox = makeVisibleStaticBox;
    this.isIn = isIn;
        
    /**
     *
     * @function
     * @description funkcia vytvori vo worlde novu staticky box
     * @param x {int} 
     * @param y {int} 
     * @param width {int} sirka boxu
     * @param height {int} vyska boxu                    
     */         
    function makeStaticBox(x,y,width,height){
        var boxSd = new b2BoxDef();
        boxSd.friction =  0.5;
        boxSd.restitution =  0.0;
        var halfWidth = width/2;
        var halfHeight = height/2;
        boxSd.extents.Set(halfWidth, halfHeight);
        var boxBd = new b2BodyDef();
        boxBd.AddShape(boxSd);
        boxBd.position.Set(x + halfWidth, y + halfHeight);
        var box = this.world.CreateBody(boxBd);   
        box.m_flags |= b2Body.e_staticFlag;
        return box;
    }
       
    /**
     * @function
     * @description funkcia vytvori vo worlde novu staticky box s texturou
     * @param x {int} 
     * @param y {int} 
     * @param width {int} sirka boxu
     * @param height {int} vyska boxu                    
     */                         
    function makeVisibleStaticBox(x,y,width,height){
        var wallBitmap = Game._game.bitmaps[path+"steel.jpg"];
        var box = this.makeStaticBox(x,y,width,height);
                    
        var wall = new Sprite();
        wall.addChild(wallBitmap);
        wall.x = x;
        wall.y = y;
        wall.scaleX = width/ 30;
        wall.scaleY = height/ 322;
        this.level.addChild(wall);       
        return box;
    }

        
    function makeBox(hrubka){
        var x = this.x;
        var y = this.y;
        var w = this.width;
        var h = this.height;
        // floor
        this.makeVisibleStaticBox(x,y + h - hrubka,w,hrubka);
        // left wall
        this.makeVisibleStaticBox(x,y,hrubka,h);
        // right wall
        this.makeVisibleStaticBox(x + w - hrubka,y,hrubka,h);
    }    
                    
    function isIn(x,y){
        var w = this.width;
        var h = this.height; 
        var result = x > this.x;
        result &= x < (this.x + w);
        result &= y > this.y;
        result &= y < (this.y + h);
        return result;
    }
}